package figurex;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.MouseInfo;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextField;

public final class usercontrol extends JApplet {
	 public static void main(String[] args) {
		    usercontrol main = new usercontrol();
		    showmainWindow(main,500,500);
		    main.Xusercontrol();
		  }
	 
	public void Xusercontrol(){
		while(true){
			usercontrol maintest = new usercontrol();
		    int mouseY = MouseInfo.getPointerInfo().getLocation().y;
		    int mouseX = MouseInfo.getPointerInfo().getLocation().x;  
			//System.out.println("Repainting.........");
			//System.out.println(mouseX + "-" + mouseY);
			//repaint();

			try{
				Thread.sleep(1000);
			} catch(InterruptedException e){
				break;
			}
		}
	}
	
	 
  //hard-coded the selected item
  //@TODO: can be listed in the Description.xml, then parse from the xml to the engine database
  //       NEED to build the database 
  private String[] description = { 
		  "Eat Lunch", 
		  "Eat Dinner", 
		  "Eat breakfast",
          "Watch movie", 
          "Call taxi", 
          "Want a Party(XOXO - 1-10)",
          "Want a Party(XOXO - 2)"
          };
  
  private JTextField t = new JTextField(15);
  private JComboBox c = new JComboBox();
  private JButton search = new JButton("let's go");
  private int count = 0;
  private JComboBox output = new JComboBox();


  public static void showmainWindow(JApplet applet, int width, int height) {
    JFrame frame = new JFrame("FigureXLife");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(applet);
    frame.setSize(width, height);
    frame.setResizable(false);
    frame.repaint();
    applet.init();
    applet.start();
    frame.setVisible(true);

  }
  
  public void init() {
	  
	    for (int i = 0; i < description.length; i++)
	      c.addItem(description[count++]);
	    t.setEditable(false);
	    count = 0;
	    c.addActionListener(new ActionListener() {
	      public void actionPerformed(ActionEvent e) {
	        t.setText("Task:" + c.getSelectedIndex() + "   "
	            + ((JComboBox) e.getSource()).getSelectedItem());
	        
	      }
	    });
	    Container cp = getContentPane();
	    cp.setLayout(new FlowLayout());
	    cp.add(t);
	    cp.add(c);
	    cp.add(search);
	    search.setLocation(990, 515);
	    //cp.add(output);
	  }
}